package jolly;

import java.util.Random;

/**
 * @author 航
 * @date 2025/02/15 00:09
 * 游戏背景：恐怖地铁站游戏，一局游戏一共八次选择，每次选择前进或后退，八次正确答案随机，八次全部选对才能通关
 * 尝试：如果在全随机的情况在，多少次才能碰巧通关一局游戏？
 **/
public class OneGame {


    /**
     * 总共选择次数
     */
    private final int COUNT = 8;

    /**
     * 统计玩家一共游玩几局
     */
    public Integer userPlayCount;

    /**
     * 开启一局游戏
     * @return ture通关  false未通关
     */
    public boolean oneCount(){
        Random random = new Random();
        for(int i = 0; i < COUNT; i++){
            if(random.nextBoolean() != random.nextBoolean()){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        OneGame oneGame = new OneGame();
        oneGame.userPlayCount = 0;
        boolean result = false;
        while (!result){
            result = oneGame.oneCount();
            oneGame.userPlayCount++;
        }
        System.out.println(oneGame.userPlayCount);
    }
}
